How can i make this Python code less repetitive

welcome to shbcf.ru